package en.edu.zucc.pb.loginapplication.adapter;

import android.content.Context;
import android.text.format.DateUtils;
import android.util.TimeUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.List;

import en.edu.zucc.pb.loginapplication.R;
import en.edu.zucc.pb.loginapplication.model.Bookkeeping;
import en.edu.zucc.pb.loginapplication.util.DateUtil;

public class BookkeepingAdapter extends BaseAdapter {

//    private LinkedList<Animal> mData;
    private List<Bookkeeping> mData;
//    https://blog.csdn.net/qq_30211165/article/details/78290999
    private Context mContext;

    public BookkeepingAdapter(List<Bookkeeping> mData, Context mContext) {
        this.mData = mData;
        this.mContext = mContext;
    }

    @Override
    public int getCount() {
        return mData.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        convertView = LayoutInflater.from(mContext).inflate(R.layout.item_bookkeeping_cons,parent,false);
        ImageView img = (ImageView) convertView.findViewById(R.id.img);
        TextView title = (TextView) convertView.findViewById(R.id.title);
        TextView date = (TextView) convertView.findViewById(R.id.date);
        img.setBackgroundResource(mData.get(position).getIcon());
        title.setText(mData.get(position).getTitle());
//        TimeUtils.

        date.setText(DateUtil.dateToString(mData.get(position).getDate(),DateUtil.LONG_DATE_FORMAT));
        return convertView;
    }
}
//————————————————
//版权声明：本文为CSDN博主「江苏小白龙」的原创文章，遵循CC 4.0 BY-SA版权协议，转载请附上原文出处链接及本声明。
//原文链接：https://blog.csdn.net/qq_30211165/article/details/78290999